package com.huanling.main.keyconflictdealer;

import cn.hutool.json.JSONUtil;
import com.huanling.main.exception.ConflictKeyException;

import java.util.Map;
import java.util.Objects;

/**
 * 严格模式，直接抛错并终止比对
 *
 * @author guibo.sun
 * @since 25 七月 2021
 */
public class ConflictBreakDealer extends AbstractConflictKeyDealer {

    @Override
    void preDeal(ConflictKeyContext conflictKeyContext, String key, Map<String, Object> oldValue, Map<String, Object> newValue) {
        if (Objects.nonNull(oldValue)) {
            ConflictKeyException.of("参照列冲突！旧数据列:" + JSONUtil.toJsonStr(oldValue) + "新数据列:" + JSONUtil.toJsonStr(newValue))
                    .throwException();
        }
    }
}
